package com.draw.server.service;

import java.util.List;

import javax.jws.WebService;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.draw.core.Drawing;
import com.draw.core.Vector;
import com.draw.server.hibernate.HibernateUtil;
import com.draw.webinterface.VectorInterface;

@WebService(targetNamespace = "http://draw.some.com/", serviceName = "VectorService", name = "VectorService")
public class VectorService implements VectorInterface {
	private static final Logger logger = LoggerFactory
			.getLogger(VectorService.class);

	@Override
	public List<Vector> getVectorListFromDrawing(Drawing drawing) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Boolean addVectorList(List<Vector> list) {
		logger.info("Inserting vectors : {}", list);
		Session session = HibernateUtil.getSession();
		Transaction tx = session.beginTransaction();
		for( Vector vector : list ) {
			session.save(vector);
		}
		tx.commit();
		return new Boolean(true);
	}

}
